import { createRouter, createWebHashHistory } from 'vue-router'
import { routes } from './routes'
import { useUserStore } from '@/stores'


const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to, form) => {

  document.title = `虫共名-${to.meta.title}`

  const store = useUserStore()
  const whiteList = ["/login"]

  if (!store.token && !whiteList.includes(to.path)) return '/login'
})

export default router
